//package com.lcdpg.lcdp.gateway.config;
//
//import org.springframework.cloud.client.discovery.DiscoveryClient;
//import org.springframework.cloud.gateway.route.RouteLocator;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
///**
// * @author admin
// * @version 1.0.0
// * @ClassName SwaggerRouteLocator.java
// * @Description TODO
// * @createTime 2025年05月29日 09:21:00
// */
//@Configuration
//public class SwaggerRouteLocator {
//    @Bean
//    @Primary  // 覆盖默认实现
//    public SwaggerResourcesProvider gatewaySwaggerResourcesProvider(
//            RouteLocator routeLocator,
//            DiscoveryClient discoveryClient) {
//
//        return () -> routeLocator.getRoutes()
//                .filter(route -> route.getUri().getHost() != null)
//                .filter(route -> discoveryClient.getInstances(route.getUri().getHost()).size() > 0)
//                .map(route -> createResource(route.getUri().getHost()))
//                .collectList()
//                .block();
//    }
//
//    private SwaggerResource createResource(String serviceId) {
//        SwaggerResource resource = new SwaggerResource();
//        resource.setName(serviceId);
//        resource.setUrl("/" + serviceId + "/v3/api-docs");  // OpenAPI 3标准路径
//        resource.setSwaggerVersion("3.0");
//        return resource;
//    }
//}
